import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { ColorConfig } from "../../resource/ColorConfig";
import { EColor } from "../../../../Message/Public/EColor";
import { GTextFormat } from "../../../common/GTextFormat";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { EKillEvilType } from "../../../../Message/Game/EKillEvilType";
import { GameConst } from "../../../component/gconst/GameConst";
import { KillEvilPropItem } from "./KillEvilPropItem";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GModuleEvent } from "../../mvc/GModuleEvent";
import { Cache } from "../../cache/Cache";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class PublishKillEvilTaskPanel
    
    export  class PublishKillEvilTaskPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.createChildren();
            this.addListeners();
            return;
        }

        protected createChildren(): void
        {
            ObjCreate.createBg(0, 0, 548, 226, this);
            ObjCreate.createBg(0, 231, 548, 160, this);
            ObjCreate.createBg(0, 56, 548, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(0, 354, 548, 2, this, ImagesConst.SplitLine);
            var loc1=HTMLUtil.addColor(Language.getString(90164), ColorConfig.instance.getItemColor(EColor._EColorOrange).color) + Language.getString(90165) + HTMLUtil.addColor(Language.getString(90166), ColorConfig.instance.getItemColor(EColor._EColorGreen).color) + "、" + HTMLUtil.addColor(Language.getString(90167), ColorConfig.instance.getItemColor(EColor._EColorBlue).color) + "、" + HTMLUtil.addColor(Language.getString(90168), ColorConfig.instance.getItemColor(EColor._EColorPurple).color) + "、" + HTMLUtil.addColor(Language.getString(90169), ColorConfig.instance.getItemColor(EColor._EColorOrange).color) + Language.getString(90170);
            var loc2=ObjCreate.createGTextField("", 5, 8, 520, 50, this, new GTextFormat(null, null, GlobalStyle.color1Uint, null, null, null, null, null, null, 10, 0, 25, 5));
            loc2.filters = [FilterConst.glowFilter];
            loc2.wordWrap = true;
            loc2.htmlText = loc1;
            this.createPropItem(43, 73, EKillEvilType._EKillEvilTypeHuman);
            this.createPropItem(173, 73, EKillEvilType._EkillEvilTypeEarth);
            this.createPropItem(303, 73, EKillEvilType._EkillEvilTypeHeaven);
            this.createPropItem(433, 73, EKillEvilType._EkillEvilTypeGod);
            ObjCreate.createLabel(Language.getString(90172), 15, 148, 126, 20, flash.text.TextFormatAlign.CENTER, this, true, ColorConfig.instance.getItemColor(EColor._EColorGreen).intColor);
            ObjCreate.createLabel(Language.getString(90173), 145, 148, 126, 20, flash.text.TextFormatAlign.CENTER, this, true, ColorConfig.instance.getItemColor(EColor._EColorBlue).intColor);
            ObjCreate.createLabel(Language.getString(90174), 275, 148, 126, 20, flash.text.TextFormatAlign.CENTER, this, true, ColorConfig.instance.getItemColor(EColor._EColorPurple).intColor);
            ObjCreate.createLabel(Language.getString(90175), 405, 148, 126, 20, flash.text.TextFormatAlign.CENTER, this, true, ColorConfig.instance.getItemColor(EColor._EColorOrange).intColor);
            this._expLabelGreen = ObjCreate.createLabel("", 15, 166, 126, 20, flash.text.TextFormatAlign.CENTER, this, false, GlobalStyle.color1Uint);
            this._expLabelBlue = ObjCreate.createLabel("", 145, 166, 126, 20, flash.text.TextFormatAlign.CENTER, this, false, GlobalStyle.color1Uint);
            this._expLabelPurple = ObjCreate.createLabel("", 275, 166, 126, 20, flash.text.TextFormatAlign.CENTER, this, false, GlobalStyle.color1Uint);
            this._expLabelOrange = ObjCreate.createLabel("", 405, 166, 126, 20, flash.text.TextFormatAlign.CENTER, this, false, GlobalStyle.color1Uint);
            this._publishBtnGreen = ObjCreate.createGButton(Language.getString(90188), 25, 184, 106, 26, this, "ButtonSpecial");
            this._publishBtnBlue = ObjCreate.createGButton(Language.getString(90188), 155, 184, 106, 26, this, "ButtonSpecial");
            this._publishBtnPurple = ObjCreate.createGButton(Language.getString(90188), 285, 184, 106, 26, this, "ButtonSpecial");
            this._publishBtnOrange = ObjCreate.createGButton(Language.getString(90188), 415, 184, 106, 26, this, "ButtonSpecial");
            ObjCreate.createLabel(Language.getString(90189), 5, 240, 150, 20, flash.text.TextFormatAlign.LEFT, this, true, 16777181);
            this._propOwnLabelGreen = ObjCreate.createLabel("", 28, 260, 330, 20, flash.text.TextFormatAlign.LEFT, this, true, ColorConfig.instance.getItemColor(EColor._EColorGreen).intColor);
            this._propOwnLabelBlue = ObjCreate.createLabel("", 28, 278, 330, 20, flash.text.TextFormatAlign.LEFT, this, true, ColorConfig.instance.getItemColor(EColor._EColorBlue).intColor);
            this._propOwnLabelPurple = ObjCreate.createLabel("", 28, 296, 330, 20, flash.text.TextFormatAlign.LEFT, this, true, ColorConfig.instance.getItemColor(EColor._EColorPurple).intColor);
            this._propOwnLabelOrange = ObjCreate.createLabel("", 28, 314, 330, 20, flash.text.TextFormatAlign.LEFT, this, true, ColorConfig.instance.getItemColor(EColor._EColorOrange).intColor);
            var loc3=GameConst.ReleaseKillEvilTaskTime_start < 10 ? "0" + GameConst.ReleaseKillEvilTaskTime_start : "" + GameConst.ReleaseKillEvilTaskTime_start;
            var loc4=GameConst.ReleaseKillEvilTaskTime_end < 10 ? "0" + GameConst.ReleaseKillEvilTaskTime_end : "" + GameConst.ReleaseKillEvilTaskTime_end;
            ObjCreate.createLabel(Language.getString(90190) + loc3 + "：30 - " + loc4 + "：30", 150, 366, 548, 20, flash.text.TextFormatAlign.LEFT, this, true, GlobalStyle.color1Uint);
            this._remainTimesLabel = ObjCreate.createLabel(Language.getString(90191), 5, 366, 200, 20, flash.text.TextFormatAlign.LEFT, this, false, GlobalStyle.color1Uint);
            this._getKillEvilTaskBtn = ObjCreate.createGButton(Language.getString(90192), 385, 250, 126, 26, this, "ButtonSpecial");
            var loc5=Language.getString(90193);
            var loc6;
            (loc6 = ObjCreate.createGTextField("", 385, 280, 158, 85, this, new GTextFormat(null, null, GlobalStyle.color1Uint, null, null, null, null, null, null, null, null, null, 2))).wordWrap = true;
            loc6.htmlText = loc5;
            return;
        }

        protected addListeners(): void
        {
            this._publishBtnGreen.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._publishBtnBlue.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._publishBtnPurple.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._publishBtnOrange.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._getKillEvilTaskBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            return;
        }

        /* internal  */createPropItem(arg1: int, arg2: int, arg3: int): void
        {
            var loc1=null;
            (loc1 = new KillEvilPropItem(arg3)).x = arg1;
            loc1.y = arg2;
            this.addChild(loc1);
            return;
        }

        /* internal  */onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target;
            switch (loc1) 
            {
                case this._publishBtnGreen:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.KillEvilTaskPublishTask, EKillEvilType._EKillEvilTypeHuman));
                    break;
                }
                case this._publishBtnBlue:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.KillEvilTaskPublishTask, EKillEvilType._EkillEvilTypeEarth));
                    break;
                }
                case this._publishBtnPurple:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.KillEvilTaskPublishTask, EKillEvilType._EkillEvilTypeHeaven));
                    break;
                }
                case this._publishBtnOrange:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.KillEvilTaskPublishTask, EKillEvilType._EkillEvilTypeGod));
                    break;
                }
                case this._getKillEvilTaskBtn:
                {
                    this.dispatchEvent(new DataEvent(GModuleEvent.KillEvilTaskChangeCurrentPanel, 1, false, true, true));
                    break;
                }
            }
            return;
        }

        public updateReleaseInfo(): void
        {
            var loc1=Cache.instance.killEvilTask.releaseInfo;
            this._expLabelGreen.htmlText = Language.getStringByParam(90194, loc1.expHuman.toString());
            this._expLabelBlue.htmlText = Language.getStringByParam(90194, loc1.expEarth.toString());
            this._expLabelPurple.htmlText = Language.getStringByParam(90194, loc1.expHeaven.toString());
            this._expLabelOrange.htmlText = Language.getStringByParam(90194, loc1.expGod.toString());
            var loc2=Cache.instance.killEvilTask.getKillEvilPropNumInfo();
            this._propOwnLabelGreen.htmlText = Language.getStringByParam(90195, loc2._killEvilTaskPropNum_Green.toString(), loc1.releaseHuman.toString(), loc1.gotHuman.toString());
            this._propOwnLabelBlue.htmlText = Language.getStringByParam(90196, loc2._killEvilTaskPropNum_Blue.toString(), loc1.releaseEarth.toString(), loc1.gotEarth.toString());
            this._propOwnLabelPurple.htmlText = Language.getStringByParam(90197, loc2._killEvilTaskPropNum_Purple.toString(), loc1.releaseHeaven.toString(), loc1.gotHeaven.toString());
            this._propOwnLabelOrange.htmlText = Language.getStringByParam(90198, loc2._killEvilTaskPropNum_Orange.toString(), loc1.releaseGod.toString(), loc1.gotGod.toString());
            this._remainTimesLabel.htmlText = Language.getStringByParam(90199, loc1.canReleaseCount.toString());
            return;
        }

        /* internal */ /* var */_expLabelGreen: GLabel;

        /* internal */ /* var */_expLabelBlue: GLabel;

        /* internal */ /* var */_expLabelPurple: GLabel;

        /* internal */ /* var */_expLabelOrange: GLabel;

        /* internal */ /* var */_publishBtnGreen: GButton;

        /* internal */ /* var */_publishBtnBlue: GButton;

        /* internal */ /* var */_publishBtnPurple: GButton;

        /* internal */ /* var */_publishBtnOrange: GButton;

        /* internal */ /* var */_propOwnLabelGreen: GLabel;

        /* internal */ /* var */_propOwnLabelBlue: GLabel;

        /* internal */ /* var */_propOwnLabelPurple: GLabel;

        /* internal */ /* var */_propOwnLabelOrange: GLabel;

        /* internal */ /* var */_remainTimesLabel: GLabel;

        /* internal */ /* var */_getKillEvilTaskBtn: GButton;
    }
